using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class SavePoint : MonoBehaviour
{
    public GameObject playerPrefab;
    void Awake()
    {
        if (GameObject.FindWithTag("Player") == null)
        {
            LoadGame();
        }
        else
        {
            GameObject.FindWithTag("Player").transform.position = transform.position;
        }
    }

    public void LoadGame()
    {
        GameObject player = Instantiate(playerPrefab);
        player.transform.position = transform.position;
        PlayerController.instance.Load();
        WorldMap.instance.Load();
        if (PlayerController.instance.nowScene != SceneManager.GetActiveScene().name)
        {
            SceneManager.LoadScene(PlayerController.instance.nowScene);
        }
    }
}
